home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / VIEWGET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  1.7 KB  |  54 lines

  1. /* viewget.c - get_cmd functions - get an input command  */
  2. #include "stdio.h"
  3. #include "cminor.h"
  4. #include "viewcmds.h"
  5. #include "viewparm.h"
  6.  
  7. /* definition of key values returned by getkey    */
  8. #include "keyio.h"
  9.  
  10. int get_cmd()            /* get next input command from keyboard */
  11.  {                /* returns the command type entered    */
  12.   int key ;            /* holds the keyboard input value    */
  13.                 /* ( see keyio.h ) for values        */
  14.   int cmd ;            /* holds the command type value     */
  15.  
  16.   prompt() ;            /* display prompts            */
  17.   cmd = INVALIDCMD ;        /* setup for key entry test        */
  18.   while( cmd == INVALIDCMD )
  19.     { key = getkey() ;        /* get next keyboard input        */
  20.       switch( key )        /* clasify the key pressed        */
  21.     {
  22.     case  PGDNKEY    :  cmd = NEXTPAGE    ;break    ;
  23.     case  PGUPKEY    :  cmd = PREVPAGE    ;break    ;
  24.     case  ASCESC    :  cmd = EXITPGM    ;break    ;
  25.     case  ' '       :  cmd = MOVETOPOS      ;break  ;
  26.     case  HOMEKEY    :  cmd = FIRSTPAGE    ;break    ;
  27.     case  ENDKEY    :  cmd = LASTPAGE    ;break    ;
  28.     case  UPARROW    :  cmd = PREVLINE    ;break    ;
  29.     case  DOWNARROW :  cmd = NEXTLINE    ;break    ;
  30.     default     :  cmd = INVALIDCMD    ;
  31.     } /* end of switch statement  */
  32.       }
  33.     return(cmd) ;
  34.   }
  35.  
  36. int prompt()            /* display prompts            */
  37.   {
  38. #define UP_A  24        /* displays up arrow            */
  39. #define DN_A  25        /* displays down arrow            */
  40.  
  41.     printf( "\n           Type one of these Input Commands") ;
  42.     printf( "\n HOME    = First Page      ") ;
  43.     printf(   "  %c     = Previous Line   ",UP_A) ;
  44.     printf(    "PG UP   = Previous Page ") ;
  45.     printf( "\n END     = Last Page       ") ;
  46.     printf(   "  %c     = Next Line       ",DN_A) ;
  47.     printf(    "PG DN   = Next Page ") ;
  48.     printf( "\n ESC     = Exit Program    ") ;
  49.     printf(    "SPACE   = Move to position ");
  50.   }
  51.  
  52.  
  53.  
  54.